/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gm.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Med EL MOUDDENE
 */
@Entity
@Table(name = "ordonnance")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ordonnance.findAll", query = "SELECT o FROM Ordonnance o"),
    @NamedQuery(name = "Ordonnance.findByIdOrdonnance", query = "SELECT o FROM Ordonnance o WHERE o.idOrdonnance = :idOrdonnance"),
    @NamedQuery(name = "Ordonnance.findByDateOrd", query = "SELECT o FROM Ordonnance o WHERE o.dateOrd = :dateOrd")})
public class Ordonnance implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_ORDONNANCE")
    private Integer idOrdonnance;
    @Lob
    @Size(max = 65535)
    @Column(name = "LIBELLE")
    private String libelle;
    @Column(name = "DATE_ORD")
    @Temporal(TemporalType.DATE)
    private Date dateOrd;
    @JoinColumn(name = "ID_PERSONNE", referencedColumnName = "ID_PERSONNE")
    @ManyToOne(optional = false)
    private Personne idPersonne;

    public Ordonnance() {
    }

    public Ordonnance(Integer idOrdonnance) {
        this.idOrdonnance = idOrdonnance;
    }

    public Integer getIdOrdonnance() {
        return idOrdonnance;
    }

    public void setIdOrdonnance(Integer idOrdonnance) {
        this.idOrdonnance = idOrdonnance;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public Date getDateOrd() {
        return dateOrd;
    }

    public void setDateOrd(Date dateOrd) {
        this.dateOrd = dateOrd;
    }

    public Personne getIdPersonne() {
        return idPersonne;
    }

    public void setIdPersonne(Personne idPersonne) {
        this.idPersonne = idPersonne;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOrdonnance != null ? idOrdonnance.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ordonnance)) {
            return false;
        }
        Ordonnance other = (Ordonnance) object;
        if ((this.idOrdonnance == null && other.idOrdonnance != null) || (this.idOrdonnance != null && !this.idOrdonnance.equals(other.idOrdonnance))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gm.entities.Ordonnance[ idOrdonnance=" + idOrdonnance + " ]";
    }
    
}
